package com.example.hdwx.myapplication.adapter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;

import com.example.hdwx.myapplication.base_activity.WebActivity;
import com.example.hdwx.myapplication.eneity.daydaycook_eneitys.Daydaycook_eneity;
import com.example.hdwx.myapplication.untils.ImageShow;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;

import java.util.List;

/**
 * Created by hdwx on 2017/2/15.
 */


/*图片轮播适配器*/
public class RollPagerAdapter extends StaticPagerAdapter {
    List <Daydaycook_eneity>list;
    Context context;
    String string;
    RollPagerAdapter(List <Daydaycook_eneity>list, Context context){
        this.list=list;
        this.context=context;


    }

    @Override
    public View getView(ViewGroup container, final int position) {
        ImageView imageView=new ImageView(container.getContext());
        new ImageShow().image_show(container.getContext(),list.get(position).getImg_url(),imageView);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, WebActivity.class);
                intent.putExtra("id",list.get(position).getId());
                intent.putExtra("url",list.get(position).getUrl_id());
                context.startActivity(intent);
            }
        });
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        return  imageView;
    }
    @Override
    public int getCount() {
        return list.size();
    }
}
